﻿// Write a program that reads a text file and prints on the console its odd lines.

using System;
using System.IO;
using System.Text;

class PrintTextFileOddLines
{
    static void Main()
    {
        try
        {
            string path = @"../../PrintTextFileOddLines.cs";
            using (StreamReader reader = new StreamReader(path))
            {
                int lineNumber = 1;
                string line = reader.ReadLine();
                while (line != null)
                {
                    if (lineNumber % 2 != 0)
                    {
                        Console.WriteLine(line);
                    }

                    line = reader.ReadLine();
                    lineNumber++;
                }
            }
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
        catch
        {
            Console.WriteLine("Fatal error occurred.");
        }
    }
}
